/*    */ package com.newcrm.db;
/*    */ 
/*    */ import com.newcrm.manager.LuceneManager;
/*    */ import java.sql.Connection;
/*    */ import java.sql.SQLException;
/*    */ import org.apache.commons.dbutils.DbUtils;
/*    */ import org.apache.commons.dbutils.QueryRunner;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class DeleteCustomerManager
/*    */ {
/* 21 */   private static Logger logger = Logger.getLogger(DeleteCustomerManager.class
/* 22 */     .getName());
/*    */ 
/*    */   public void clearDeletedCustomer(String filePath)
/*    */   {
/* 31 */     Connection conn = ConnectionManager.getInstance().getConnection();
/* 32 */     if (conn == null) {
/* 33 */       return;
/*    */     }
/*    */ 
/* 36 */     QueryRunner runner = new QueryRunner();
/*    */     try
/*    */     {
/*    */       try
/*    */       {
/* 41 */         runner.update(conn, "UPDATE T_Customer_Info AS A INNER JOIN T_Customer_Info AS B ON A.ParentCustomerId = B.CustomerId AND B.DeleteFlag = 1 AND B.Type = 0 AND B.ParentCustomerId = -1 SET A.DeleteFlag = 1, A.IndexFlag = 0 WHERE A.Type = 1");
/*    */       } catch (SQLException e) {
/* 43 */         logger.warn("update people delete flag failed", e);
/*    */       }
/*    */ 
/* 47 */       LuceneManager.getInstance(filePath).indexCustomers(conn, false);
/*    */       try
/*    */       {
/* 51 */         runner.update(conn, "DELETE FROM T_Customer_Ext_Info WHERE CustomerId IN (SELECT CustomerId FROM T_Customer_Info WHERE DeleteFlag = 1)");
/*    */       } catch (SQLException e) {
/* 53 */         logger.warn("delete customer extInfo failed", e);
/*    */       }
/*    */ 
/*    */       try
/*    */       {
/* 58 */         runner.update(conn, "DELETE FROM T_Customer_Tag_Info WHERE CustomerId IN (SELECT CustomerId FROM T_Customer_Info WHERE DeleteFlag = 1)");
/*    */       } catch (SQLException e) {
/* 60 */         logger.warn("delete customer tag relation failed", e);
/*    */       }
/*    */ 
/*    */       try
/*    */       {
/* 65 */         runner.update(conn, "DELETE FROM T_Deal_Info WHERE CustomerId IN (SELECT CustomerId FROM T_Customer_Info WHERE DeleteFlag = 1)");
/* 66 */         runner.update(conn, "DELETE FROM T_Customer_Deal_Info WHERE CustomerId IN (SELECT CustomerId FROM T_Customer_Info WHERE DeleteFlag = 1)");
/*    */       } catch (SQLException e) {
/* 68 */         logger.warn("delete customer deal failed", e);
/*    */       }
/*    */ 
/*    */       try
/*    */       {
/* 73 */         runner.update(conn, "DELETE FROM T_ImportantDate_Info WHERE CustomerId IN (SELECT CustomerId FROM T_Customer_Info WHERE DeleteFlag = 1)");
/*    */       } catch (SQLException e) {
/* 75 */         logger.warn("delete customer impotant date failed", e);
/*    */       }
/*    */ 
/*    */       try
/*    */       {
/* 80 */         runner.update(conn, 
/* 81 */           "DELETE FROM T_Customer_Permissions_Change_Info WHERE CustomerId IN (SELECT CustomerId FROM T_Customer_Info WHERE DeleteFlag = 1)");
/*    */       } catch (SQLException e) {
/* 83 */         logger.warn("delete customer permission change info failed", e);
/*    */       }
/*    */ 
/*    */       try
/*    */       {
/* 88 */         runner.update(conn, 
/* 89 */           "DELETE FROM T_Customer_Category_Change_Info WHERE CustomerId IN (SELECT CustomerId FROM T_Customer_Info WHERE DeleteFlag = 1)");
/*    */       } catch (SQLException e) {
/* 91 */         logger.warn("delete customer category change info failed", e);
/*    */       }
/*    */ 
/*    */       try
/*    */       {
/* 96 */         runner.update(conn, "DELETE FROM T_Customer_Permissions_Info WHERE CustomerId IN (SELECT CustomerId FROM T_Customer_Info WHERE DeleteFlag = 1)");
/*    */       } catch (SQLException e) {
/* 98 */         logger.warn("delete customer permission change info failed", e);
/*    */       }
/*    */ 
/*    */       try
/*    */       {
/* 103 */         runner.update(conn, "DELETE FROM T_Customer_Info WHERE DeleteFlag = 1 AND IndexFlag = 1");
/*    */       } catch (SQLException e) {
/* 105 */         logger.warn("delete customer info failed", e);
/*    */       }
/*    */     } finally {
/*    */       try {
/* 109 */         DbUtils.close(conn);
/*    */       } catch (SQLException e) {
/* 111 */         logger.warn("close conn failed", e);
/*    */       }
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.db.DeleteCustomerManager
 * JD-Core Version:    0.6.1
 */